require "Common/define"
require "Logic/Config"
require "Common/functions"

TowerSortItemList = {};
HelperFunc.SetUIEnv(TowerSortItemList)
local this = TowerSortItemList;

this.playerHead = nil
this.rank = nil
this.rankController = nil
this.ranking = nil
this.playerName = nil
this.guildName = nil
this.towerLevel = nil
this.time = nil

function TowerSortItemList.initData(obj,data)
    playerHead = obj:GetChild("playerHead");
    playerHead.touchable = true;
    rank = obj:GetChild("rank")
    rankController = rank:GetController("rank");
    rankController.selectedIndex = 0
    ranking = rank:GetChild("ranking")
    playerName = obj:GetChild("playerName")
    guildName = obj:GetChild("guildName")
    towerLevel = obj:GetChild("towerLevel")
    time = obj:GetChild("time")


    if data ~= nil then
        rankController.selectedIndex = data.rank >= 1 and data.rank <= 3 and data.rank or 0
        ranking.text = data.rank
        playerName.text = data.name
        guildName.text = ""
        towerLevel.text = data.param;
        time.text = data.time;
        --local ctrlItem = CtrlManager.GetCtrl(PanelNames.HeadRectItem);
        --
        --if ctrlItem ~= nil then  --初始装备信息
        --    ctrlItem.initData(playerHead,data);
        --end
        local headIcon = playerHead:GetChild("head"):GetChild("icon");
        --headIcon.url = "ui://ICONAtlas/" .. data.icon;
        UIComponentInterface:SetPlayerIcon(headIcon,data.headId)
    end

end




return TowerSortItemList;